package com.example.springboot2.oa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springboot2.oa.entity.TMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TMenuMapper extends BaseMapper<TMenu> {
    @Select("SELECT" +
            "   tm.* " +
            "FROM " +
            "   t_menu tm " +
            "LEFT JOIN " +
            "   t_power tp " +
            "ON (" +
            "   tm.menu_id = tp.menu_id " +
            "   AND " +
            "   tp.role_id = #{role_id}" +
            ") " +
            "WHERE " +
            "   IFNULL(tp.status, 0) = #{status} " +
            "ORDER BY tm.menu_id")
    List<TMenu> powerByRole(
            @Param("status") Integer status,
            @Param("role_id") String  roleId);
}
